package com.wang.mall.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wang.mall.bean.UmsMemberReceiveAddress;
import com.wang.mall.model.R;
import com.wang.mall.service.impl.UmsMemberReceiveAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class MemberAddressController {


    @Autowired
    UmsMemberReceiveAddressService memberReceiveAddressService;


    @GetMapping("/address/getId")
    public R<UmsMemberReceiveAddress> getId(@RequestParam("addrId") Long addrId) {
        UmsMemberReceiveAddress byId = memberReceiveAddressService.getById(addrId);
        return R.ok(byId);
    }

    @GetMapping("/getByMemberId")
    public R<List<UmsMemberReceiveAddress>> getByMemberId(@RequestParam Long memberId) {
        List<UmsMemberReceiveAddress> list = memberReceiveAddressService.list(new LambdaQueryWrapper<UmsMemberReceiveAddress>().eq(UmsMemberReceiveAddress::getMemberId, memberId));
        return R.ok(list);
    }
}
